package cn.com.gainfo.bktas.dao;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.sql.DataSource;

import cn.com.gainfo.bktas.vo.PaytypeVO;
import cn.yzyue.base.dao.AbstractDAO;
import cn.yzyue.base.tools.db.DB;
import cn.yzyue.base.tools.str.StrUtil;
import cn.yzyue.base.vo.VO;

public class PaytypeDAO extends AbstractDAO {
	
	private static final SimpleDateFormat sdf19 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	@Override
	public boolean add(DataSource dataSource, VO vo) {
		PaytypeVO ptvo = (PaytypeVO)vo;
		String sql = "insert into paytype(transtype,areacode,eftbank,startamt,endamt,type,effdate) values('";
		sql += StrUtil.get(ptvo.getTranstype()) + "','" + StrUtil.get(ptvo.getAreacode()) + "','" + StrUtil.get(ptvo.getEftbank());
		sql += "','" + StrUtil.get(ptvo.getStartamt()) + "','" + StrUtil.get(ptvo.getEndamt()) + "','" + StrUtil.get(ptvo.getType());
		sql += "','" + sdf19.format(new Date()) + "')";
		return DB.alter(dataSource, sql);
	}

	@Override
	public boolean batchDel(DataSource dataSource, VO vo, List data) {
		// TODO Auto-generated method stub
		return super.batchDel(dataSource, vo, data);
	}

	@Override
	public boolean del(DataSource dataSource, VO vo, String[] ids) {
		// TODO Auto-generated method stub
		return super.del(dataSource, vo, ids);
	}

	@Override
	public VO findByIds(DataSource dataSource, VO vo, String[] ids) {
		// TODO Auto-generated method stub
		return super.findByIds(dataSource, vo, ids);
	}

	@Override
	public boolean mod(DataSource dataSource, VO vo) {
		PaytypeVO ptvo = (PaytypeVO)vo;
		String sql = "update paytype set transtype = '";
		sql += StrUtil.get(ptvo.getTranstype()) + "',areacode = '" + StrUtil.get(ptvo.getAreacode()) + "',eftbank = '" + StrUtil.get(ptvo.getEftbank());
		sql += "',startamt = '" + StrUtil.get(ptvo.getStartamt()) + "',endamt = '" + StrUtil.get(ptvo.getEndamt()) + "',type = '" + StrUtil.get(ptvo.getType());
		sql += "',effdate = '" + sdf19.format(new Date()) + "' where id = '" + ptvo.getId() + "'";
		return DB.alter(dataSource, sql);
	}

}
